<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends MY_Controller {

	function __construct() {
		parent::__construct();		
	}
	
	function test_get_tabs() {
		$data = $this->_get_menu_tabs();
		echo "<pre>";
		print_r($data);
	}
	
	function index() {
		$data = $this->type_model->get_table_fields();
		$data = implode(', ', $data);
		echo $data;
	}
	
	function test_time() {
		echo date('Y/m/d h:m:s A', 1999999999);//1314670665
	}
	
	function session() {
		echo "<pre>";
		//print_r($this->session->userdata(SESSION_SOCIETY_LOGO_THUMB));
		print_r($_SESSION);
	}
	
	function read_constants() {
		$this->load->helper('file');
		$path = $_SERVER['DOCUMENT_ROOT'] . "/" . SYSTEM_FOLDER . "/application/config/constants.php";
		$string = read_file($path);
		
		$str_pattern = "/define\('SITE_NAME_FULL', '(.*?)'\);/";
		preg_match($str_pattern, $string, $result);
		print_r($result);
	}
	
	function read_csft() {
		$this->load->helper('file');
		$path = $_SERVER['DOCUMENT_ROOT'] . "/" . SYSTEM_FOLDER . "/coreseek/etc/csft.conf";
		$string = read_file($path);
		
		$str_pattern = "/sql_host = (.*)/";
		preg_match($str_pattern, $string, $result);
		print_r($result);
		
		//$str = preg_quote("\$db['default']['hostname'] = 'localhost';");
		//echo $str;
	}
	
	function rename_folder() {
		$file = $_SERVER['DOCUMENT_ROOT'] . "/" . SYSTEM_FOLDER . "/application/controllers/slll";
		$rename = $_SERVER['DOCUMENT_ROOT'] . "/" . SYSTEM_FOLDER . "/application/controllers/sl";
		if (rename($file, $rename)) { 
			echo ""; 
		} else { 
			echo ""; 
		}
	}
	
	function read_news_img() {
		$this->load->helper('file');
		$path = $_SERVER['DOCUMENT_ROOT'] . "/" . SYSTEM_FOLDER . "/news.txt";
		$string = read_file($path);
		
		$str_pattern = "/<img alt=\"\" src=\"(.*)\" \/>/";
		preg_match($str_pattern, $string, $result);
		//preg_match_all($str_pattern, $string, $result);
		
		echo "<pre>";
		print_r($result);
	}
	
	function info() {
		echo "<pre>";
		print_r(phpinfo());
	}
	
	function path() {
		echo base_url();
		echo "<pre>";
		print_r($_SERVER);
		echo "<br />";
		print_r($_COOKIE);
	}
	
	function read_xml() {
		$this->load->helper('file');
		$path = $_SERVER['DOCUMENT_ROOT'] . "/" . SYSTEM_FOLDER . "/js/plugin/piecemaker/piecemaker.xml";
		$string = read_file($path);
		
		$str_pattern = "/<Image Id=\"society_festival\" Source=\"(.*)\" Title=\"(.*)\"><Text>(.*)<\/Text><Hyperlink URL=\"(.*)\" Target=\"_blank\" \/><\/Image>/";
		preg_match($str_pattern, $string, $result);
		//preg_match_all($str_pattern, $string, $result);
		
		echo "<pre>";
		print_r($result);
	}
	
	function replace() {
		$str = '199139';
		$par = "/[\x80-\xff]/";
		echo preg_replace($par,"",$str);
	}

	function test_md5() {
		$string = "9352";
		echo md5($string);
		echo "<br />";
		echo sha1($string);
	}
	
	function test_download() {
		$this->load->helper('file');
		$this->load->helper('download');
		$data = 'Here is some text!';
		$name = 'mytext.sql';
		force_download($name, $data);
	}
	
	function test_cookie() {
		$temp = urldecode("7835d0e87f1e89dba619719c4f96bf9b%3A271094efaf67b60f7b3b851814f2d453");
		echo $temp;
	}
}